<?php if (!defined('THINK_PATH')) exit();?><!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="renderer" content="webkit">
    <meta http-equiv="Cache-Control" content="no-siteapp" />
    <meta name="keywords" content="广东国防教育学会">
    <meta name="description" content="广东国防教育学会">
    <title>广东国防教育学会</title>
    <link rel="shortcut icon" href="/Public/Admin/img/favicon.ico">
    <link href="/Public/Admin/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
    <link href="/Public/Admin/css/font-awesome.min93e3.css?v=4.4.0" rel="stylesheet">
    <link href="/Public/Admin/css/style.min862f.css?v=4.1.0" rel="stylesheet">
    <link rel="stylesheet" href="/Public/Admin/bootstrap_validator-0.4.5/dist/css/bootstrapValidator.css"/>
    <link href="/Public/Admin/css/animate.min.css" rel="stylesheet">
    <link href="/Public/Admin/plugins/iCheck/all.css" rel="stylesheet">
    <style>
		/* *{
			color:#000;
		} */
		.btn{
		 	 padding: 5px 8px;
		 	 /* border-radius: 0px; */
			font-size:12px;
			margin-bottom:0px;
		}
		.table{
	    	width: 100%;
		}
		.table>tbody>tr>td, .table>tbody>tr>th, .table>tfoot>tr>td, .table>tfoot>tr>th, .table>thead>tr>td, .table>thead>tr>th{
			padding:0px 5px;
			/*text-align: center;*/
			vertical-align: middle!important;
		}
		.form-control{
			font-size: 12px;
		}
		#file-pretty button{
			padding: 7.5px 13px;
		}
		p{
	   		 margin: 0 0;
		}
		.pagination{
			margin:0px 0px;
		}
		.select_width{
			width:100px;
		}
		.select_no_border{
			border-right: none;
		}
	</style>
</head>
    
    <style>
		.icheck_float_left{
			float:left;
		}
	</style>

<body class="gray-bg">
    <div class="wrapper wrapper-content animated fadeInRight">
        <div class="row">
            <div class="col-sm-12">
                <div class="ibox float-e-margins">
                    <div class="ibox-title">
                        <h5>分配权限</h5>
                        <div class="ibox-tools">
                            <a class="collapse-link">
                                <i class="fa fa-chevron-up"></i>
                            </a>
                            <a class="close-link">
                                <i class="fa fa-times"></i>
                            </a>
                        </div>
                    </div>
                    <div class="ibox-content">
                        <div class="">
                            <a href="#" class="btn btn-primary dim" aria-controls="messages" role="button" data-toggle="modal" data-target="#myModal"><span class="fa fa-plus"></span> 为<span style="color:red"><?php echo ($group_data['title']); ?></span>分配权限</a>
                        </div>
                        <br/>
                        <div class="table-responsive">
					  
					     	 
  <form action="/Admin/UserGroup/ruleGroup" method="post">
	<input type="hidden" name="id" value="<?php echo ($group_data['id']); ?>">
	<div class="table-responsive">
	<table class="table table-bordered">
		<?php if(is_array($rule_data)): foreach($rule_data as $key=>$v): if(empty($v['_data'])): ?><tr class="b-group">
					<th width="10%">
					<div class="i-check icheck_float_left one_lever">
						<label>
							<?php echo ($v['title']); ?>
							<input type="checkbox" name="rule_ids[]" value="<?php echo ($v['id']); ?>" <?php if(in_array($v['id'],$group_data['rules'])): ?>checked="checked"<?php endif; ?> onclick="checkAll(this)" >
						</label>
					</div>
					</th>
					<td></td>
				</tr>
			<?php else: ?>
				<tr class="b-group">
					<th width="10%">
					<div class="i-check icheck_float_left one_lever" >
						<label>
							<?php echo ($v['title']); ?> <input type="checkbox" name="rule_ids[]" value="<?php echo ($v['id']); ?>" <?php if(in_array($v['id'],$group_data['rules'])): ?>checked="checked"<?php endif; ?> onclick="checkAll(this)" >
						</label>
					</div>
					</th>
					<td class="b-child">
						<?php if(is_array($v['_data'])): foreach($v['_data'] as $key=>$n): ?><table class="table table-bordered">
								<tr class="b-group">
									<th width="15%">
									<div class="i-check icheck_float_left two_lever">
										<label>
											<?php echo ($n['title']); ?> <input type="checkbox" name="rule_ids[]" value="<?php echo ($n['id']); ?>" <?php if(in_array($n['id'],$group_data['rules'])): ?>checked="checked"<?php endif; ?> onclick="checkAll(this)">
										</label>
									</div>
									</th>
									<td>
										<?php if(!empty($n['_data'])): if(is_array($n['_data'])): $i = 0; $__LIST__ = $n['_data'];if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$c): $mod = ($i % 2 );++$i;?><div class="i-check icheck_float_left">
												<label>
													&emsp;<?php echo ($c['title']); ?> <input type="checkbox" name="rule_ids[]" value="<?php echo ($c['id']); ?>" <?php if(in_array($c['id'],$group_data['rules'])): ?>checked="checked"<?php endif; ?> >
												</label>
											</div><?php endforeach; endif; else: echo "" ;endif; endif; ?>
									</td>
								</tr>
							</table><?php endforeach; endif; ?>
					</td>
				</tr><?php endif; endforeach; endif; ?>
		<tr>
			<th></th>
			<td>
				<input class="btn btn-primary" type="submit" value="提交">
			</td>
		</tr>
	</table>
	</div>
</form>
     					 </div>
                    </div>
                </div>
            </div>
        </div>
    </div>


<script src="/Public/Admin/js/jquery.min.js?v=2.1.4"></script>
<script src="/Public/Admin/js/bootstrap.min.js?v=3.3.6"></script>
<!-- <script src="/Public/Admin/js/content.min.js?v=1.0.0"></script> -->
<script type="text/javascript" src="/Public/Admin/bootstrap_validator-0.4.5/dist/js/bootstrapValidator.js"></script>
<script src="/Public/Admin/plugins/layer/layer.js"></script>
<script src="/Public/Admin/plugins/iCheck/icheck.min.js"></script>

<script>
//设置checkbox按钮
$('.i-check').iCheck({
	checkboxClass : "icheckbox_square-green",
	radioClass : "iradio_square-green",
});
</script>

</body>
</html>

<script>
$(document).ready(function() {
    /**
     * 下面是进行插件初始化
     * 你只需传入相应的键值对
     * */
    $('#defaultForm').bootstrapValidator({
            message: 'This value is not valid',
            feedbackIcons: {/*输入框不同状态，显示图片的样式*/
            	  valid: 'glyphicon glyphicon-ok',
                  invalid: 'glyphicon glyphicon-remove',
                  validating: 'glyphicon glyphicon-refresh'
            },
            fields: {/*验证*/
            	title: {/*键名username和input name值对应*/
                    message: '用户组名验证失败',
                    validators: {
                        notEmpty: {/*非空提示*/
                            message: '用户组名不能为空'
                        },
                        stringLength: {/*长度提示*/
                            min: 4,
                            max: 30,
                            message: '用户组名长度必须在4到30之间'
                        }/*最后一个没有逗号*/
                    }
                }
            }
            // 还有一个比较常用的就是submitHandler属性，它对应着提交按钮的事件方法。
            // submitHandler: function (validator, form, submitButton) {
                //alert("submit");
               /*  var menu_name = $("input[name='menu_name']").val();
                var link = $("input[name='link']").val();
                var ico = $("input[name='ico']").val();
                $.ajax({
                    url : '/Admin/UserGroup/addMenu',
                    type : 'get',
                    data : {'menu_name' : menu_name, 'link' : link, 'ico':ico},
                    dataType : 'json',
                    success : function(data){
                      alert(data.message);
                    }
                }); */
           // }
        });
});

//选择按钮
$(".one_lever .iCheck-helper").click(function(){
		var getClass = $(this).parents("div").attr("class");
		if(getClass == 'icheckbox_square-green hover checked'){
			$(this).parents('.b-group').eq(0).find(".b-child").find(".i-check").iCheck('check');
		}else{
			$(this).parents('.b-group').eq(0).find(".b-child").find(".i-check").iCheck('uncheck');
		}
});

$(".two_lever .iCheck-helper").click(function(){
	var getClass = $(this).parent("div").attr("class");
	if(getClass == 'icheckbox_square-green hover checked'){
		$(this).parent('div').parent('label').parent('div').parent('th').siblings('td').find(".i-check").iCheck('check');
	}else{
		$(this).parent('div').parent('label').parent('div').parent('th').siblings('td').find(".i-check").iCheck('uncheck');
	} 
});

</script>
</body>
</html>